﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using L = Science.Mathematics.LinearAlgebra;

namespace Strang3Ed.Chapter03.Section6
{
    public class ExampleA
    {
        public ExampleA()
        {
        }
        private string result;
        public string Result
        {
            get { return result; }
        }
        public void Compute()
        {
            double[,] x = { { 1.0, 0.0, 0.0 } ,
                            { 2.0, 1.0, 0.0 },
                            { 5.0, 0.0, 1.0 }};

            L.Matrix Ei = new L.Matrix(x);

            double[,] y = { { 1.0, 3.0, 0.0, 5.0 } ,
                            { 0.0, 0.0, 1.0, 6.0 },
                            { 0.0, 0.0, 0.0, 0.0 }};

            L.Matrix Ro = new L.Matrix(y);

            L.Matrix A = Ei * Ro;

            L.ColumnSpace C = new L.ColumnSpace(A);
            foreach (L.Vector v in C.Basis)
                result += v.ToString() + "\r\n";
            result += C.Dimension.ToString() + "\r\n" + "\r\n";

            L.LeftNullspace LN = new L.LeftNullspace(A);
            foreach (L.Vector v in LN.Basis)
                result += v.ToString() + "\r\n";
            result += LN.Dimension.ToString() + "\r\n" + "\r\n";

            L.RowSpace R = new L.RowSpace(A);
            foreach (L.Vector v in R.Basis)
                result += v.ToString() + "\r\n";
            result += R.Dimension.ToString() + "\r\n" + "\r\n";

            L.Nullspace N = new L.Nullspace(A);
            foreach (L.Vector v in N.Basis)
                result += v.ToString() + "\r\n";
            result += N.Dimension.ToString() + "\r\n";
        }
    }
}
/*
1
2
5

0
1
0

2

-5
-8.88178419700125E-16
1

1

1
3
0
5

2
6
1
16

2

-3
1
0
0

-5
0
-6
1

2
*/


